#define _CRT_SECURE_NO_WARNINGS 1
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
#include <stdio.h>
#include <stdlib.h>
int* sortArrayByParity(int* A, int ASize){
	int left = 0; int right = ASize-1;
	while (left < right)
	{
		//jishu 
		while (A[left] % 2 == 0)
		{
			left++;
		}
		//hou
		while (A[right] % 2 != 0)
		{
			right--;
		}
		//jiaohuan
		int tem = A[right];
		A[right] = A[left];
		A[left] = tem;
		left++;
		right--;
	}
	return A;
}

int main()
{
	int arr[4] = { 3, 1, 2, 4 };
	sortArrayByParity(arr,4);
	for (int i = 0; i < 4; i++)
	{
		printf("%d\n", arr[i]);
	}

	system("pause");
	return 0;
}